#ifndef _INCLUDE_ONET_S_TCP_PEER_
#define _INCLUDE_ONET_S_TCP_PEER_

/*!
    Copright: Kai "DrHalan" Mast - www.freakybytes.org

    This file is part of OpenNetwork. See OpenNetwork.h for license information.
*/

#ifdef __WINDOWS__
#include <winsock2.h>
#elif defined(__unix__)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#else
#error "What's your operating system?"
#endif

#include <list>

#include <BitStream/BitStream.h>
#include <OpenNetwork/OpenNetwork.h>

namespace onet
{

    struct STCPPeer
    {
        STCPPeer(const SNetworkAddress& addr_, const s32 socketfd_) :
                address(addr_), socketfd(socketfd_), connected(false), cache(0), msgSize(0), msgType(EMT_Ping)
        {
        }

        ~STCPPeer()
        {
            if (cache)
                delete cache;
        }

        //! Network Addres
        const SNetworkAddress address;

        //! The Socket FileDescriptor
        const s32 socketfd;

        //! Is already connected?
        bool connected;

        //! Stuff for caching messages (the ones sent in serveral chunks)
        //! Data Cache
        BitStream *cache;
        //! Message Size
        u32 msgSize;
        //! Message type
        u8  msgType;
    };

} //!end namespace onet

#endif
